guiags
Posts: 29
|
Posted: 02/17/2010, 4:49 AM |
|
Hi everybody,
I am happy to write in this forum because people are very ...
This is my problem, i want to make dynamic submenu according to a databse. I already know how to make dynamic menu but for the submenu, i don't know. I check in the other topics and i saw this link: http://forums.codecharge.com/posts.php?pm_id=1381&post_id=43048
I followed it and i didn't understand anything.
Please, is it possible to help me with a non complicated solution
Thanks
|
|
|
guiags
Posts: 29
|
Posted: 02/23/2010, 12:36 AM |
|
Hi everybody,
since my last post, i found solution for my problem and i tried something and it walk perfectly. What i did is that, i made a static menu with the menu builder and it create a class for that. I modified that class by putting my sql request before the creation of the menu's elements and i made a loop to take all the submenu of any menu. The modified class look like this:
//Class_Initialize Event
function clsMenuHeaderMainMenu($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->ComponentName = "MainMenu";
$this->Visible = True;
$this->controls = array();
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->ErrorBlock = "Menu MainMenu";
$this->StaticItems = array();
// my personal code to retrive my menus
$i = 0; //pour indexer les menu
$db = new clsDBConnect();
$db->query("SELECT id_menu, DESIGNATION FROM menu WHERE visible='OUI'");
while ($db->next_record()) // loop to retrieve menu
{
$i++;
$id_menu = $db->f("id_menu");
$designation = $db->f("DESIGNATION");
// creation of item by modifiying the generated one
$this->StaticItems[] = array("item_id" => "MenuItem".$i, "item_id_parent" => null, "item_caption" => $designation, "item_url" => array("Page" => "page_pub.php?ID_MENU=".$id_menu."&menu=".$designation, "Parameters" => null), "item_target" => "", "item_title" => "");
$j = 0; //pour indexer les sous menus
$db_smenu = new clsDBConnect();
// Query to retrieve all the submenu of a menu
$db_smenu->query("SELECT id_sous_menu, DESIGNATION_SS FROM sous_menu WHERE visible='OUI' AND ID_MENU=".$id_menu);
while ($db_smenu->next_record()) // loop to retrieve submenu
{
$j++;
$id_smenu = $db_smenu->f("id_sous_menu");
$designation_ss = $db_smenu->f("DESIGNATION_SS");
$this->StaticItems[] = array("item_id" => "MenuItem".$i."Item".$j, "item_id_parent" => "MenuItem".$i, "item_caption" => $designation_ss, "item_url" => array("Page" => "page_pub.php?ID_MENU=".$id_menu."&menu=".$designation."&ID_SOUS_MENU=".$id_smenu."&DESIGNATION_SS=".$designation_ss, "Parameters" => null), "item_target" => "", "item_title" => "");
}
} // end of the personal code
$this->DataSource = new clsHeaderMainMenuDataSource($this);
$this->ds = & $this->DataSource;
$this->DataSource->SetProvider(array("DBLib" => "Array"));
parent::clsMenu("item_id_parent", "item_id", null);
$this->ItemLink = & new clsControl(ccsLink, "ItemLink", "ItemLink", ccsText, "", CCGetRequestParam("ItemLink", ccsGet, NULL), $this);
$this->controls["ItemLink"] = & $this->ItemLink;
$this->ItemLink->Page = $this->RelativePath . "page_pub.php";
$this->LinkStartParameters = $this->ItemLink->Parameters;
}
//End Class_Initialize Event
I hope that this can help someone
|
|
|
|